<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>非行间样式</title>
</head>
<style>
    .box{
        width: 200px;
        height: 200px;
        background-color: lightsalmon;
    }
</style>
<body>
    <div class="box">
        这是一个盒子
    </div>
</body>
<script>
    function getStyle(obj,attr){
        if(obj.currentStyle){
            return obj.currentStyle[attr]
        }else{
            return getComputedStyle(obj)[attr]
        }
    }
    let box = document.getElementsByClassName("box")[0];
    console.log(box);
    console.log(getStyle(box,"width"));
</script>
</html>